package com.quanyue.haircut.user.mapper;

import com.quanyue.haircut.domain.entity.HaircutMerchant;
import com.quanyue.haircut.user.dto.MerchantDetail;
import com.vhuomai.mybatis.mapper.auto.AutoMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface HaircutMerchantMapper extends AutoMapper <HaircutMerchant, Integer> {
    HaircutMerchant findByMerchantNo(@Param("merchantNo") Integer merchantNo);

    @Select("select m.id as manager_id, m.image, m.user_name, m.password, m.nick_name, m.merchant_no as merchant_number, a.* "
            + "from qy_manager m "
            + "left join qy_haircut_merchant a on a.merchant_no = m.merchant_no "
            + "where m.father_id = #{fatherId} and m.del_flag = 0")
    List <MerchantDetail> findByFatherId(@Param("fatherId") Integer fatherId);

    @Select("select sum(o.pay_price) from qy_reserve_order o where o.order_status = 'DONE' and o.merchant_no = ${merchantNo} ")
    BigDecimal findTurnoverByMerchant(@Param("merchantNo") Integer merchantNo);
}
